package com.pdd.service.impl;

import com.pdd.beans.User;
import com.pdd.dao.UserMappper;
import com.pdd.service.UserService;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户业务实现
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    @Setter
    private UserMappper userMappper;

    /**
     * 添加用户信息
     *
     * @param user
     * @return
     */
    public boolean addUser(User user) {
        return userMappper.insertUser(user)>0;
    }

    /**
     * 删除用户信息
     *
     * @param id
     * @return
     */
    public boolean delUser(int id) {
        return userMappper.deleteUser(id)>0;
    }

    /**
     * 修改用户信息
     *
     * @param user
     * @return
     */
    public boolean uplUser(User user) {
        return userMappper.updateUser(user)>0;
    }

    /**
     * 查询所有用户信息
     *
     * @return
     */
    public List<User> getUser() {
        return userMappper.selectUser();
    }

    /**
     * 根据ID查询用户信息
     *
     * @param id
     * @return
     */
    public User getById(int id) {
        return userMappper.selectById(id);
    }
}
